/*
*  LLMessageBox_android.cpp
*  
*
*  Created by Alexander Trutchenko on 11/02/12.
*  Copyright 2012 Free Team. All rights reserved.
*
*/

#include "lid_lib/src/service/LLMessageBox.h"

#include "lid_lib/src/service/android/LLJniHelper.h"
#include "lid_lib/src/service/LLLog.h" 

#include <android/log.h>
#include <jni.h>

namespace lidlib {

void ll_MessageBox(const char * pszMsg, const char * pszTitle)
{
	if (! pszMsg)
	{
		return;
	}

	LLJniMethodInfo t;
	if (LLJniHelper::getStaticMethodInfo(t
		, "com/lidlib/lib/LidlibCommon"
		, "showMessageBox"
		, "(Ljava/lang/String;Ljava/lang/String;)V"))
	{
		jstring stringArg1;

		if (! pszTitle)
		{
			stringArg1 = t.env->NewStringUTF("");
		}
		else
		{
			stringArg1 = t.env->NewStringUTF(pszTitle);
		}

		jstring stringArg2 = t.env->NewStringUTF(pszMsg);
		t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2);

		t.env->DeleteLocalRef(stringArg1);
		t.env->DeleteLocalRef(stringArg2);
		t.env->DeleteLocalRef(t.classID);
	}
}

} // namespace lidlib
